﻿using System;
using System.Windows.Data;
using System.Text;
using ReflectionStudio.Core;
using WPFExcelReport;
namespace ReflectionStudio.Controls
{
    /// <summary>
    /// Converter : Boolean to System.Windows.Visibility and not revert
    /// </summary>
    [ValueConversion(typeof(string), typeof(System.Windows.Visibility))]
    public class PreisConverter : IValueConverter
    {
        /// <summary>
        /// IValueConverter.Convert
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return "";
            if (value.GetType().ToString().Contains("DBNull"))
                return "";
            if (((string)value).Trim() == "")
                return 0;
            double price = System.Convert.ToDouble(value)*0.001;
            //0000012000
            return price;
        }

        /// <summary>
        /// IValueConverter.ConvertBack (not implemented)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
           
            byte[] b;
            string filevalue = "";
            if (value == null)
                return "";
            BaseFunction m_data=new BaseFunction();
            //0000455000
            //0000000000
            filevalue = m_data.Right("0000000000" + (System.Convert.ToDouble(value) * 1000).ToString(), 10);
            return filevalue;
        }
    }
}
